package com.zcf.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zcf.common.json.Body;
import com.zcf.pojo.RoomsParam;
import com.zcf.pojo.UserBean;
import com.zcf.service.ChangeCardImpl;
import com.zcf.vo.out.LayuiJson;

@CrossOrigin
@Controller
@RequestMapping("/change")
public class ChangeCardController {

	@Autowired
	ChangeCardImpl  cc ;
	/*
	 * 后台获取房间列表
	 */
	@PostMapping("getrooms")
	@ResponseBody
	public LayuiJson getrooms(@RequestParam(value = "pageNum")int pageNum, @RequestParam(value = "roomName")String roomName,
			@RequestParam(value = "pageSize") int pageSize){
		return cc.getrooms(pageNum,pageSize,roomName);
	}
	/*
	 * 外围获取房间列表
	 */
	@PostMapping("getRooms")
	@ResponseBody
	public LayuiJson getRooms(UserBean userBean){
		return cc.getRooms(userBean);
	}
	/**
	 * 获取房间用户信息
	 * @param pageNum
	 * @param pageSize
	 * @param param
	 * @return
	 */
	@PostMapping("getusers")
	@ResponseBody
	public LayuiJson getusers(@RequestParam(value = "pageNum")int pageNum, 
			@RequestParam(value = "pageSize") int pageSize,RoomsParam param){
		return cc.getusers(pageNum,pageSize,param);
	}
	/**
	 * 获取房间内剩下的牌
	 * @param pageNum
	 * @param pageSize
	 * @param param
	 * @return
	 */
	@PostMapping("getcards")
	@ResponseBody
	public LayuiJson getcards(RoomsParam param){
		return cc.getcards(param);
	}

	/**
	 * 修改用户手中的牌
	 * @param pageNum
	 * @param pageSize
	 * @param param
	 * @return
	 */
	@PostMapping("changecard")
	@ResponseBody
	public Body changecard(@RequestParam(value = "userid")int userid, @RequestParam(value = "oldCard")int oldCard, 
			@RequestParam(value = "newCard")int newCard, RoomsParam param){
		return cc.changecard(userid,param,oldCard,newCard);
	}

}
